using Napier
using Base.Test
using FactCheck

facts("Testing basics") do
  for (i, (n, e)) in enumerate([
    (0.0001, -9.210340),
    (0.001, -6.907755),
    (0.01, -4.605169),
    (0.1, -2.302584),
    (1, 0),
    (2, 0.693147),
    (e, 1), # e=EULER CONSTANT
    (3, 1.098612),
    (4, 1.386293),
    (5, 1.609437),
    (6, 1.791759),
    (7, 1.945910),
    (8, 2.079441),
    (9, 2.197224),
    (10, 2.302584),
    (20, 2.995732),
    (30, 3.401197),
    (40, 3.688879),
    (50, 3.912023),
    (60, 4.094344),
    (70, 4.248495),
    (80, 4.382026),
    (90, 4.499809),
    (100, 4.605169),
    (200, 5.298317),
    (300, 5.703782),
    (400, 5.991464),
    (500, 6.214607),
    (600, 6.396929),
    (700, 6.551080),
    (800, 6.684611),
    (900, 6.802395),
    (1000, 6.907755),
    (10000, 9.210340)
  ])
    r = ln(n)
    r2 = trunc(r, 6)
    @fact r2 --> e "Mismatch at [$i] r => ln($n)=$r, r2 => trunc(r, 6))=$r2"
  end

  @fact_throws DomainError ln(0)
  @fact_throws DomainError ln(-0.5)
  @fact_throws DomainError ln(-5)
end

@test 1 == 1
